package wyklad;

import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;

public class CyklZycia extends javax.servlet.http.HttpServlet implements javax.servlet.Servlet {
	public CyklZycia() {
		super();
      System.out.println("CyklZycia konstruktor");
	}   	

   @Override
   public void init() throws ServletException {
      System.out.println(getServletName()+" : init()");
      String mojParametr1 = getInitParameter("mojParametr1");
      String mojParametr2 = getInitParameter("mojParametr2");
      String mojParametr3 = getInitParameter("mojParametr3");
      System.out.println(getServletName()+" ("+mojParametr1+","+mojParametr2+","+mojParametr3+")");
   }
   
   @Override
   public void destroy() {
      System.out.println(getServletName()+" : destroy()");
   }
   
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
	   doPost(request, response);
   }  	
	
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
      response.setContentType("text/html;charset=utf8");
      PrintWriter pw = response.getWriter();
      pw.println("<html>");
      pw.println("<head>");
      pw.println("   <title>GetPostServlet</title>");
      pw.println("</head>");
      pw.println("<body>");
      pw.println("   <h3>"+getServletName()+"</h3>");
      pw.println("</body>");
      pw.println("</html>");
      pw.close();  
	}   	  	    
}